import axios from 'axios'
import { takeEvery, put } from 'redux-saga/effects'
import { API } from '../../config'
import { search_action, search_action_success } from '../actions/search'

function* search_actions(action) {
    const res = yield axios.get(`${API}/products/search`, { params: action.payload })
    yield put(search_action_success({results: res.data}))
}

export default function* searchSaga() {
    yield takeEvery(search_action, search_actions)
}